package com.novunda.tool.qrcode;

import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

/**
 * @author linfeng
 * @since 2016/11/10
 */
public class QR8bitByte {

    private int mode;
    private byte[] data;

    public QR8bitByte(String data) {
        this.mode = QRMode.MODE_8BIT_BYTE;
        this.data = data.getBytes(Charset.forName("UTF-8"));
    }

    public int getLength() {
        return this.data.length;
    }

    public void write(QRBitBuffer buffer) {
        for (int i = 0; i < this.data.length; i++) {
            // not JIS ...
            buffer.put((int) this.data[i], 8);
        }
    }

    public int getMode() {
        return mode;
    }

}
